package com.hexacta.hrs.repositories.staffing.impl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.hexacta.hrs.domain.staffing.Project;
import com.hexacta.hrs.repositories.staffing.ProjectRepository;

public class ProjectRepositoryHibernateTemplateImpl extends HibernateDaoSupport implements ProjectRepository {

	public void saveOrUpdate(Object o) {
        this.getHibernateTemplate().saveOrUpdate(o);
        return;
    }
    
    public void delete(Project project) {
        this.getHibernateTemplate().delete(project);
    }
    
    public Project findById(long id) {
    	Project Project = (Project) this.getHibernateTemplate().get(Project.class, Long.valueOf(id));
    	return Project;
    }
    
    @SuppressWarnings("unchecked")
    public List<Project> findByName(String name) {
    	List<Project> Projects = this.getHibernateTemplate().find("from " + Project.class.getSimpleName() + " where name = '" + name + "'");
    	return Projects;
    }
    
    @SuppressWarnings("unchecked")
	public List<Project> findAll() {
    	List<Project> projects = this.getHibernateTemplate().find("from " + Project.class.getSimpleName());
    	return projects;
    }
}
